package com.yanqu.road.server.gameplayer.module.activity.shushanmodule;

import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.base.GeneralModule;
import com.yanqu.road.server.manger.activity.shushan.ShuShanMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.protocol.ClientProtocol;

/**
 * @Description 蜀山
 * @Author cwq
 * @Data 2022/3/8 11:31
 */
public class ShuShanModule extends GeneralModule {

    public ShuShanModule(GamePlayer player) {
        super(player);
    }

    @Override
    public boolean loadData() {
        return true;
    }

    @Override
    public boolean afterLoadData() {
        return true;
    }

    @Override
    public boolean saveData() {
        return true;
    }

    public void initSystem(){
        sendConfigToClient();
        initUserData();
        synUserData();
    }

    public void initUserData(){

    }

    @Override
    public void afterLogin() {
        sendConfigToClient();
        synUserData();
    }

    public void synUserData(){
        if (ShuShanMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuShan.getValue()) || ShuShanMgr.getConfig() == null) {
            return;
        }
        ShuShanMgr.synUserData(player,true);
    }

    /**
     * 同步配置
     */
    public void sendConfigToClient() {
        if (ShuShanMgr.getActivityInfo() == null || !SystemOpenMgr.systemOpen(player, eSystemId.ShuShan.getValue()) || ShuShanMgr.getConfig() == null) {
            return;
        }
        player.sendPacket(ClientProtocol.U_SHUSHAN_CONFIG, ShuShanMgr.builderSyncShuShanConfigRespMsg());
    }


}
